using Provausio.Common.Objects;
using TrainingManagement.api.Models.BusinessObjects.Responses;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Skill;

namespace TrainingManagement.api.Models.BusinessLogic.Skill
{
    public class SkillUpdateOperation : BusinessOperation<BusinessObjects.Skill, GeneralResponse>
    {
        readonly SkillUpdateDataSource _skillUpdate = new SkillUpdateDataSource();

        public override GeneralResponse Run(BusinessObjects.Skill input)
        {
            var resp = new GeneralResponse();
            if (_skillUpdate.Execute(input))
            {
                resp.Message = string.Format("\"{0}\" was updated successfully.", input.Title);
                resp.StatusCode = 200;
                return resp;
            }

            resp.Message = string.Format("\"{0}\" was not updated.", input.Title);
            resp.StatusCode = 500;
            return resp;
        }
    }
}